package com.cloud.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class MyWebMvcConfigurerAdapter extends WebMvcConfigurerAdapter {

    //图片存放根路径
//    @Value("${file.staticAccessPath}")
//    private String staticAccessPath;
//    @Value("${file.rootPath}")
//    private String rootPath;

    //图片存放根目录下的子目录
//    @Value("${file.sonPath}")
//    private String sonPath;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry){
//        String filePath = "file:" + rootPath + sonPath;
        //指向外部目录
//        registry.addResourceHandler(staticAccessPath).addResourceLocations(filePath);
        registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
        super.addResourceHandlers(registry);
    }
}